/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Request;

import java.io.Serializable;
import java.net.InetAddress;
import java.util.HashMap;

/**
 *
 * @author Zhang Ying
 */
public class GeneralRequest extends Request implements Serializable {

    protected HashMap ContentTable;
    public enum GRType{Invitation, Join}

    public GeneralRequest()
    {
        super(RequestType.GENERAL);
        ContentTable = new HashMap();
    }

    public GeneralRequest(GRType rType)
    {
        super(RequestType.GENERAL);
        ContentTable = new HashMap();
        ContentTable.put("Request Type", rType);
    }

    public GeneralRequest(HashMap aContentTable)
    {
        super(RequestType.GENERAL);
        ContentTable = aContentTable;
    }

    public void setRequestType(GRType rType)
    {
        ContentTable.put("Request Type", rType);
    }

    public GRType getRequestType()
    {
        return (GRType)ContentTable.get("Request Type");
    }

    public void setRecord(String key, Object value)
    {
        ContentTable.put(key, value);
    }

    public Object getFieldValue(String key)
    {
        return ContentTable.get(key);
    }

    public HashMap GetRequestContent()
    {
        return ContentTable;
    }

    @Override
    public void SetLocalInetAddr(InetAddress addr)
    {
          _local_ip_addr = addr;
          ContentTable.put("srcIP", addr);
    }

    @Override
    public void SetLocalPort(int port)
    {
        _local_port = port;
        ContentTable.put("srcPort", port);
    }

    /**
     * @return return a list designated ``ip'' addresses separated by whitespace,
     * or null means all current connected users
     */
    public String getDestAddresses(){return null;}

    /**
     *
     * @return a list of ports
     */
    public String getDestPorts(){return null;}

    /**
     *
     * @return return the number of addresses, -1 means all
     */
    public int getDestCount(){return -1;}

    
    public String getDestAddress(int index){return "";}

    public int getDestPort(int index){return -1;}
}
